build: Add an option to use more conservative GResource embedding
authorSimon McVittie <smcv@debian.org>
Mon, 15 Aug 2022 21:24:26 +0000 (22:24 +0100)
committerSimon McVittie <smcv@debian.org>
Tue, 16 Aug 2022 08:23:59 +0000 (09:23 +0100)
Doing clever things with objcopy is faster, but also doesn't work on
all toolchains and architectures: in particular, Debian has had trouble
with this on arm and mips.

Developers will want to leave this option switched on for faster
incremental builds (unless their toolchain doesn't support it), but in
a distro build environment where we are compiling all of GTK every time,
the cost of potentially unreliable builds is higher than the cost of
using slower but more conservative GResource embedding.

Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/5107
Forwarded: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4956
Signed-off-by: Simon McVittie <smcv@debian.org>
Gbp-Pq: Name build-Add-an-option-to-use-more-conservative-GResource-em.patch

gtk/meson.build
meson_options.txt

index 3a8457ada7aa5c7ff7e13550f9efde23ac0df5f4..de40b91d85f999a3f812a5f5095d3823e5e82bf1 100644 (file)
@@ -864,15 +864,28 @@ if not fs.exists('theme/Default/Default-light.css')
 endif
 
 
+fast_gresource_embedding = get_option('fast_gresource_embedding')
+
 objcopy_supports_add_symbol = false
 objcopy = find_program('objcopy', required : false)
 if objcopy.found()
   objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol')
 endif
+fast_gresource_embedding = fast_gresource_embedding and objcopy_supports_add_symbol
 
 ld = find_program('ld', required : false)
+fast_gresource_embedding = fast_gresource_embedding and ld.found()
+
+if meson.is_cross_build() or build_machine.system() != 'linux'
+  fast_gresource_embedding = false
+endif
+
+if build_machine.cpu_family() in ['arm', 'mips']
+  # Known not to work reliably on these architectures
+  fast_gresource_embedding = false
+endif
 
-if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
+if fast_gresource_embedding
   glib_compile_resources = find_program('glib-compile-resources')
 
   # Create the resource blob
index bb2530d00a086854ba2fc031211b26428be36e2e..73ed3ab2e1b4649e0f5273e663dd2122e3fda3fc 100644 (file)
@@ -78,6 +78,11 @@ option('f16c',
        value: 'enabled',
        description: 'Enable F16C fast paths (requires F16C)')
 
+option('fast_gresource_embedding',
+       type: 'boolean',
+       value: true,
+       description: 'Speed up GResource compilation (does not work on all architectures)')
+
 # Documentation and introspection
 
 option('gtk_doc',